package com.ilibrary.web.action;

import java.util.List;

import sun.reflect.ReflectionFactory.GetReflectionFactoryAction;

import com.ilibrary.base.MyBaseAction;
import com.ilibrary.service.NewsCategoryService;
import com.ilibrary.service.NewsService;
import com.ilibrary.web.dto.ResultDto;
import com.ilibrary.web.vo.NewsVO;

public class NewsCenterAction extends MyBaseAction {
	
	private NewsService newsService;
	private NewsCategoryService newsCategoryService;
	
	public NewsService getNewsService() {
		return newsService;
	}
	public void setNewsService(NewsService newsService) {
		this.newsService = newsService;
	}
	public NewsCategoryService getNewsCategoryService() {
		return newsCategoryService;
	}
	public void setNewsCategoryService(NewsCategoryService newsCategoryService) {
		this.newsCategoryService = newsCategoryService;
	}
	
	@Override
	public String execute() throws Exception {
		String newsCategoryId = getRQ().getParameter("newsCategoryId");
		if(newsCategoryId == null || newsCategoryId.equals("")) {
			newsCategoryId = "ZYDT";
		}
		ResultDto<NewsVO> resultDto = newsService.queryList(0, 20, newsCategoryId, null);
		List<NewsVO> newsVOList = resultDto.getResultList();
		getRQ().setAttribute("newsVOList", newsVOList);
		getRQ().setAttribute("newsCategoryId", newsCategoryId);
		return SUCCESS;
	}
	
}
